<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
.search{
    display: flex;
}
</style>
<script src="./构造函数封装.js"></script>
<body>
    <div id="root"></div>
    <!-- 搜索框 -->
    <template name="Search">
        <div class="search">
            <input type="text" value="{{searchValue}}" oninput="search.methods.handleInputChange(event)">
            <button class="search-btn" onclick="search.methods.handleSearch()">搜索</button>
        </div>
    </template>

    <script>
        // 业务
        // 搜索框
        const search = new Component({
            name: 'Search',
            el: '#root',
            data: {
                searchValue: ''
            },
            methods: {
                handleInputChange(event){
                    this.data.searchValue = event.target.value
                },
                handleSearch(){
                    console.log('搜索:',this.data.searchValue)
                }
            },
            
        })
    </script>
</body>
</html>